import os

from flask_login import current_user
from flask_wtf import FlaskForm

from wtforms import SubmitField 


class UserFollowersForm(FlaskForm):
    follower = SubmitField("粉丝")
    followed = SubmitField("关注")

    def __init__(self, user,  **kwargs):
        super().__init__(**kwargs)
        s = "加关注" if not current_user.is_authenticated else "已关注" if user.is_following(current_user) else "加关注"
        self.follower.render_kw = {"value": f"{user.followers.count()} 粉丝", "class": "btn btn-outline-secondary"}
        self.followed.render_kw = {"value": s, "class": "btn btn-outline-secondary"}